home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 May / PCPlus May 1998=disk A.iso / trial / gdldb / disk1 / data1.cab / Example_Files / calctest.scp next >
Encoding:
Text File  |  1998-01-21  |  1.9 KB  |  87 lines

  1. ##########################################################
  2. # GDIdB demo script (c) 1997 Global Data Industries
  3. #
  4. # This script will time the time it takes you to evaluate
  5. # an arithmetic expression, and test the answer to see if
  6. # it's correct.
  7. ##########################################################
  8.  
  9.  
  10.  
  11.  
  12.  
  13. ##########################################################
  14. # declare variables used by script
  15.  
  16. &defvar(?var1?,?test?,?timeval?,?oldtime?,?time?)
  17.  
  18.  
  19.  
  20.  
  21.  
  22. ##########################################################
  23. # Print the information screen
  24.  
  25. &cls
  26. &print("Calculation Test Demo Script")
  27. &print("------------------------------------------")
  28.  
  29.  
  30.  
  31.  
  32.  
  33. ##########################################################
  34. # start script main execution loop
  35.  
  36. &do
  37. {
  38.     # get the current time in seconds
  39.     &assign(?oldtime?,?gdidbtime.h?*60*60+?gdidbtime.m?*60+?gdidbtime.s?)
  40.  
  41.     # get the user's answer to the problem
  42.     &assign(?var1?,"quit")
  43.     &input(?var1?,"What's 2+6*8\?")
  44.  
  45.     # get the new time (in seconds)
  46.     &assign(?timeval?,?gdidbtime.h?*60*60+?gdidbtime.m?*60+?gdidbtime.s?)
  47.  
  48.     # calculate the time taken to respond (in seconds)
  49.     &assign(?time?,?timeval?-?oldtime?)
  50.  
  51.     # check that ?var1? does not equal "quit"
  52.     &strtrim(?var1?,"?var1?")
  53.     &strcmp(?test?,"?var1?",ne,"quit",AND,"?var1?",ne,"")
  54.     &if(?test?)
  55.     {
  56.         &if(?var1?==2+6*8)
  57.         {
  58.             &print("Correct!")
  59.             &if(?time?<4)
  60.             {
  61.                 &print("You took ?time? seconds to answer- that was quick!")
  62.             }
  63.             &else
  64.             {
  65.                 &print("You were a bit slow though. (?time? seconds)")
  66.             }
  67.  
  68.             # user got it right, so end script
  69.             &print
  70.             &break
  71.         }
  72.         &else
  73.         {
  74.             &print("Wrong!")
  75.         }
  76.     }
  77.     &else
  78.     {
  79.         &print("What's wrong- too complicated for you\? ;-)")
  80.         &print("You took ?time? seconds to think about that.")    
  81.     }
  82.  
  83.     &msgbox(?var1?,"Do you want another go\?",yesno,iconquestion)
  84.     &cls
  85.  
  86. } &while (?var1?==6)
  87.